package dukeCE.InsightTracker;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;


public class InsightTrackerActivity extends TabActivity {
    TabHost tabHost; // The activity TabHost

	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    tabHost=getTabHost();
	    Resources res = getResources(); // Resource object to get Drawables
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, home_activity.class);

	    spec = tabHost.newTabSpec("sortByNew").setIndicator("New" )
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    intent = new Intent().setClass(this, SortByFavorites.class);
	    spec = tabHost.newTabSpec("favorites").setIndicator("Favorites")
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    

	    intent = new Intent().setClass(this, SortByName.class);
	    spec = tabHost.newTabSpec("topics").setIndicator("Topics")
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    
	    
	    
	    intent = new Intent().setClass(this, SortByPopularity.class);
	    spec = tabHost.newTabSpec("popular").setIndicator("Popular")
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    
	    
	    
	    
	    tabHost.setCurrentTab(0);
	    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
	    	
	    	        {
	    	
	    	            tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#56A0D3"));
	    	
	    	        }
	    	
	    	        tabHost.getTabWidget().setCurrentTab(0);
	    	
	    	        tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#56A0D3"));
	    	
	    	     }

	
	public void onTabChanged(String tabId) {
		        // TODO Auto-generated method stub
		        for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
		        {
		            tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#56A0D3"));
		        }
		 	        tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#56A0D3"));
	
	   }

	
}